<?php 
	include '../init.php';
	include ADMIN_PATH.'/header.php';

	$id=$_GET['id'];
	//连表查询

	$model=new Model('goods');
	//sql语句
	$sql="select
		g.id 		gid,
		g.name      gname,
		g.is_new    gnew,
		g.is_hot    ghot,
		g.is_bast   gb,
		g.price     gp,
		g.stock     gs,
		g.description gd,
		g.addtime   gtime,
		gi.name     giname,
		c.name      cname
		
		from
			goods 		g,
			goods_img   gi,
			category 	c
		
		where
			g.id=gi.goods_id
		and
			c.id=g.cate_id
		
		and
			g.id=$id
		and
			gi.is_cover=1 
		";
	$list=$model->find($sql);
	//var_dump($list);
	foreach ($list as $k => $v) 
	{
		$list[$k]['giname']=URL.'/public/uploads/'.substr($v['giname'], 0,4).'/'.substr($v['giname'], 4,2).'/'.substr($v['giname'], 6,2).'/200_'.$v['giname'];
		$list[$k]['gtime']=date('Y年m月d日',$v['gtime']);
	}

	$list=$list[0];

	$sql1="select `name` from `goods_img` where goods_id=$id and is_cover=0";
	$imglist=$model->find($sql1);
	//var_dump($imglist);
	foreach ($imglist as $ke => $val) 
	{
		$imglist[$ke]['name']=URL.'/public/uploads/'.substr($val['name'],0,4).'/'.substr($val['name'],4,2).'/'.substr($val['name'], 6,2).'/80_'.$val['name'];
	}

?>
<div class="m_right">
	<div class="m_main">
		<h1 style="font:bold 26px/40px 宋体;">商品详情</h1>
			<table border="0" cellspacing="0" cellpadding="5" style="margin-left:100px;">
				<tr>
					<td width="100">编号:</td>
					<td><?php echo $list['gid'];?></td>
				</tr>
				<tr>
					<td>商品名称:</td>
					<td><?php echo $list['gname'];?></td>
				</tr>
				<tr>
					<td>图片:</td>
					<td><img src="<?php echo $list['giname'];?>" alt="图片加载失败"></td>
				</tr>
				<tr>
					<td></td>
					<td>
					<?php foreach ($imglist as $key => $value) :?>
						<img src="<?php echo $value['name'];?>" alt="图片加载失败">
					<?php endforeach;?>
					</td>
				</tr>
				<tr>
					<td>描述:</td>
					<td><textarea cols="30" rows="5" readonly>
						<?php echo $list['gd'];?>
					</textarea></td>
				</tr>
				<tr>
					<td><a href="">修改</a></td>
					<td><a href="<?php echo ADMIN_URL;?>/goods/add_img.php?id=<?php echo $list['gid'];?>">添加图片</a></td>
				</tr>
			</table>
	</div>
</div>
<?php
	include ADMIN_PATH.'/footer.html';
?>